package jiangyeheng;

public class Main1 {
    public static void main(String[] args) {
        Goods shupian;
        shupian = new Goods(123423, "薯片", 3.3, 6.9, "陕西");
        shupian.show();
        boolean earn = shupian.isEarn(shupian.getGtin(), shupian.getPtout());
        System.out.println("是否盈利：");
        System.out.println(earn);
        Food milk = new Food(123123, "纯牛奶", 0.8, 2.9, "内蒙", "2025-5-1", "2025-5-5");
        milk.show();
        milk.checkwatherdead();
    }
}
class Goods{
    static private String Type;

    private long id;
    private String name;
    private double gtin;
    private double ptout;
    private String from;

    //构造函数
    //包含全部参数
    public Goods(long id,String name,double gtin,double ptout,String from){
        this.id=id;
        this.name=name;
        this.gtin=gtin;
        this.ptout=ptout;
        this.from=from;
    }

    //无参数构造
    public Goods(){
        this(0,"未命名",0.0,0.0,"产地未知");
    }

    //仅包含必要参数的构造
    public Goods(long id,String name,double gtin,double ptout){
        this(id,name,gtin,ptout,"产地未知");
    }

    //get和set方法
    public static String getType() {
        return Type;
    }

    public static void setType(String type) {
        Type = type;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getGtin() {
        return gtin;
    }

    public void setGtin(double gtin) {
        this.gtin = gtin;
    }

    public double getPtout() {
        return ptout;
    }

    public void setPtout(double ptout) {
        this.ptout = ptout;
    }
    //get和set方法

    //显示商品信息的方法
    public void show(){
        System.out.println("编号"+id);
        System.out.println("名称"+name);
        System.out.println("进价"+gtin);
        System.out.println("售价"+ptout);
        System.out.println("产地"+from);
    }

    public boolean isEarn(double gtin,double ptout){
        return ptout>gtin;
    }
}
class Food extends Goods{
    private String brithday;
    private String deaday;

    public Food(long id,String name,double gtin,double ptout,String from,String brithday,String deaday){
        super(id,name,gtin,ptout,from);
        this.brithday=brithday;
        this.deaday=deaday;
    }
    public void checkwatherdead(){
        System.out.println("该食品保质期到："+deaday);
    }
    public void show(){
        super.show();
        System.out.println("生产日期："+brithday);
        System.out.println(deaday+"号过期");
    }
}